Skip to content

Add support for tmux - #48

Open
ndeloof wants to merge 1 commit into
eiannone:masterfrom
ndeloof:tmux-support
Open

Add support for tmux#48
ndeloof wants to merge 1 commit into
eiannone:masterfrom
ndeloof:tmux-support

Conversation

@ndeloof

@ndeloof ndeloof commented Jul 16, 2026

Copy link
Copy Markdown

Inside tmux, TERM is usually tmux* or screen*, whose terminfo entries describe cursor keys in keypad transmit mode (kcuu1=\EOA, …). This library never emits smkx, so tmux actually sends the normal-mode sequences (\E[A, …): every arrow key is misparsed as an Alt combo (KeyEsc + rune '[') and the trailing byte is swallowed; Home/End/F-keys are garbled the same way.

tmux translates keys itself, so what it emits does not depend on the outer terminal (verified empirically with cat -v inside a pane): same as screen for Home/End (\E[1~, \E[4~) but with normal-mode cursor keys. This adds a dedicated built-in key table, selects it whenever $TMUX is set (whatever TERM is, so TERM=screen* setups are covered too), and registers tmux/tmux-256color in the built-in and compatibility tables.

Tested end-to-end on macOS with tmux 3.5: arrows, Home/End, F1/F5/F12, Insert/Delete, PgUp/PgDn and plain runes are all reported correctly, where master reports Alt-combo garbage.

🤖 Generated with Claude Code

Inside tmux, TERM is usually tmux* or screen*, whose terminfo entries
describe cursor keys in keypad transmit mode (kcuu1=\EOA, ...). This
library never emits smkx, so tmux actually sends the normal-mode
sequences (\E[A, ...): every arrow key ended up misparsed as an
Alt combo (KeyEsc + rune '[') and the trailing byte was swallowed.

tmux translates keys itself, so the sequences it emits do not depend on
the outer terminal: same as screen for Home/End (\E[1~, \E[4~) but
with normal-mode cursor keys. Add a dedicated built-in key table,
select it whenever $TMUX is set (whatever TERM is), and register
tmux/tmux-256color in the built-in and compatibility tables.

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant